@echo off
echo ============== 开始清理项目 ==============

echo 1. 删除不需要的模块目录...
rmdir /s /q btjfmall-module-erp
rmdir /s /q btjfmall-module-report
rmdir /s /q btjfmall-module-mp
rmdir /s /q btjfmall-module-bpm
rmdir /s /q btjfmall-module-crm
rmdir /s /q btjfmall-module-ai
rmdir /s /q btjfmall-module-iot
rmdir /s /q btjfmall-ui

echo 2. 执行数据库清理...
echo 2.1 删除不需要的顶级菜单...
mysql -u root -proot ruoyi_vue_pro -e "DELETE FROM system_menu WHERE id IN (1185, 1281, 2084, 2397, 2563, 2758, 2892, 1254, 2159, 2160);"

echo 2.2 删除孤立的子菜单...
mysql -u root -proot ruoyi_vue_pro -e "DELETE FROM system_menu WHERE parent_id NOT IN (SELECT id FROM (SELECT id FROM system_menu) AS TEMP) AND parent_id > 0;"

echo 2.3 清理角色-菜单关联...
mysql -u root -proot ruoyi_vue_pro -e "DELETE FROM system_role_menu WHERE menu_id NOT IN (SELECT id FROM system_menu);"

echo 2.4 清理字典数据...
mysql -u root -proot ruoyi_vue_pro -e "DELETE FROM system_dict_type WHERE type LIKE 'mp_%%' OR type LIKE 'report_%%' OR type LIKE 'erp_%%' OR type LIKE 'crm_%%' OR type LIKE 'bpm_%%' OR type LIKE 'ai_%%' OR type LIKE 'iot_%%';"
mysql -u root -proot ruoyi_vue_pro -e "DELETE FROM system_dict_data WHERE dict_type LIKE 'mp_%%' OR dict_type LIKE 'report_%%' OR dict_type LIKE 'erp_%%' OR dict_type LIKE 'crm_%%' OR dict_type LIKE 'bpm_%%' OR dict_type LIKE 'ai_%%' OR dict_type LIKE 'iot_%%';"

echo 3. 验证清理结果...
echo 3.1 查看保留的顶级菜单：
mysql -u root -proot ruoyi_vue_pro -e "SELECT id, name, parent_id FROM system_menu WHERE parent_id = 0 ORDER BY id;"

echo 3.2 查看保留的字典类型：
mysql -u root -proot ruoyi_vue_pro -e "SELECT id, name, type FROM system_dict_type ORDER BY type;"

echo ============== 清理完成 ==============
echo 当前保留的模块：
echo - btjfmall-dependencies（依赖管理）
echo - btjfmall-framework（框架核心）
echo - btjfmall-server（服务主项目）
echo - btjfmall-module-system（系统模块）
echo - btjfmall-module-infra（基础设施）
echo - btjfmall-module-member（会员模块）
echo - btjfmall-module-pay（支付模块）
echo - btjfmall-module-mall（商城模块）

pause 